package com.wandian.message.mvvm.mymessage.mycomment;

import android.os.Bundle;
import android.view.View;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.mylib.libcore.AppContext;
import com.mylib.libcore.bean.UserInfoBean;
import com.mylib.libcore.config.RouterConfig;
import com.mylib.libcore.mvvm.BaseMVVMActivity;
import com.mylib.libcore.utils.StatusBarUtils;
import com.wandian.message.R;
import com.wandian.message.adapter.MyCommentRecycleAdapter;
import com.wandian.message.adapter.MyPraiseRecycleAdapter;
import com.wandian.message.databinding.MessageActivityMyCommentBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @date 2019/12/18-14:28
 * @description 我的评论
 **/
@Route(path = RouterConfig.ROUTER_ACTIVITY_MY_MESSAGE_COMMENT)
public class MyCommentActivity extends BaseMVVMActivity<MyCommentViewModel> {
    private MessageActivityMyCommentBinding dataBinding;
    private MyCommentRecycleAdapter myCommentRecycleAdapter;
    @Override
    public void init(Bundle savedInstanceState) {
        dataBinding = DataBindingUtil.setContentView(this, R.layout.message_activity_my_comment);
        dataBinding.setLifecycleOwner(this);
        dataBinding.setViewModel(mViewModel);
        initViewData();
        initClink();
        initRecycle();
    }
    private void initViewData(){
        //设置状态颜色和字体黑色
        StatusBarUtils.with(this,false)
                .setIsActionBar(false)
                .clearActionBarShadow()
                .setDrawable(getResources().getDrawable(com.mylib.libcore.R.drawable.sys_color))
                .init();
        dataBinding.bindSysToolBar.toolBarTvTitle.setText("我的评论");

    }
    private void initClink(){
        dataBinding.bindSysToolBar.toolBarIvBack.setOnClickListener(v -> {
            finishhideSoftBoard();
            finish();
        });
    }

    private void initRecycle(){
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
        dataBinding.recycle.setLayoutManager(layoutManager);
        myCommentRecycleAdapter = new MyCommentRecycleAdapter(R.layout.message_item_my_comment);
        dataBinding.recycle.setAdapter(myCommentRecycleAdapter);
        List<String> listString = new ArrayList<>();
        listString.add("");
        listString.add("");
        listString.add("");
        listString.add("");
        myCommentRecycleAdapter.setNewData(listString);
        myCommentRecycleAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                UserInfoBean userInfoBean = AppContext.getInstance().getAppPreferencesHelper().getUserInfoBean();
                Bundle bundle = new Bundle();
                bundle.putString("title","动态");
                bundle.putString("user_id",userInfoBean.getId()+"");
                bundle.putString("user_name",userInfoBean.getNickName());
                bundle.putString("user_head",userInfoBean.getHeadPic());
                bundle.putString("form_id",userInfoBean.getId()+"");
                bundle.putString("user_des",userInfoBean.getDescription()+"");
                ARouter.getInstance().build(RouterConfig.ROUTER_ACTIVITY_SETTING_USERHEADINFO).with(bundle).navigation();

            }
        });
    }

}
